<?php include_once('header.php');?>
	<div class="main-content">
		<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
				try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
			</script>
			<ul class="breadcrumb">
				<li><a href="/admin/welcome"><i class="icon-home home-icon"></i>首页</a></li>
				<li><a href="/admin/role/role_list">管理员管理</a></li>
				<li><a href="/admin/role/role_list">角色列表</a></li>
				<li>编辑信息</li>
			</ul>
		</div>
		<div class="page-content" style="margin-top:18px;">	
			<div class="row">
				<div class="col-xs-12">
					<div style="border:1px solid #e1e1e1;">
						<div style="height:50px;"><span style="background-color:#f9f9f9;width:100px; height:40px; display:inline-block;*display:inline;*zoom; border:1px solid #e2e2e5; line-height:40px;color:#666; text-align:center;"><b>基本信息</b></span></div>				
						<form class="form-horizontal" enctype="multipart/form-data" role="form" method="post" action="/admin/role/edit"  onsubmit="return check()">
							<input type="hidden" class="form-control" id="role_id" name="role_id" value="<?=$data['role_id']?>">
							<div class="form-group">
								<label for="title" class="col-sm-1 control-label">角色名称</label>
								<div class="col-sm-2">
									<input type="text" class="form-control" id="role_name" name="role_name" value="<?=$data['role_name']?>">
								</div>
							</div>					
							<div class="form-group">
								<label for="title" class="col-sm-1 control-label">管理员角色</label>
								<div class="col-sm-1">
									<select class="form-control" id="status" name="status">
										<option value="1" <?php if($data['status'] == 1) {echo 'selected="selected"';}?>>开启</option>
										<option value="0" <?php if($data['status'] == 0) {echo 'selected="selected"';}?>>关闭</option>
									</select>
								</div>
							</div>
						 	<div class="form-group">
						   		<div class="col-sm-offset-1 col-sm-10">
									<button type="submit" id="submit" class="btn btn-primary">提交保存</button>
									<button type="submit" id="cancel" class="btn btn-warning">返回上页</button>
								</div>
						  	</div>
						</form>	
					</div>
				</div>
			</div>					
		</div>													
	</div>
<?php include_once('content.php');?>
	<link href="/public_source/www/assets/css/ace.min.css" rel="stylesheet" />	
	<link href="/public_source/www/assets/css/jquery.tag-editor.css" rel="stylesheet"/>
	<link  rel="stylesheet" href="/public_source/www/assets/css/jquery-confirm.css" />
	<link  rel="stylesheet" href="/public_source/www/css/confirm.css" />
    <script src="/public_source/www/assets/js/bootbox.min.js"></script>  
	<script src="/public_source/www/assets/js/jquery.tag-editor.min.js"></script>
	<script src="/public_source/www/assets/js/jquery-confirm.js"></script>
<?php include_once('footer.php');?>	
<script type="text/javascript">
	$(document).ready(function(){
		$("#cancel").click(function() {
			window.location.replace('/admin/role/role_list');
			return false;
		});
	});
	function check() {
	   var role_name = document.getElementById("role_name").value;
	   var role_id = document.getElementById("role_id").value;
	   var data = {role_id:role_id,role_name:role_name};
	   var bool = true;
	   if(role_name ==  null ||role_name == '') {
		   $.alert({
			    title: '提示',
			    content:'角色名不能为空',
			    confirm: function(){
			    }
			});
	        return false;
	   }
	   $.ajax({
			url:"/admin/role/check_sole",
			async: false,
			type:"post",
			data: data,
			dataType: 'json',
			success:function(data) {
				bool = data;
			}	
		});
		if(!bool) {
		   	$.alert({
			    title: '提示',
			    content:'角色名已存在',
			    confirm: function(){
			    }
			});
			 return false;	
		}
	   return true;
	} 			
</script>		